package com.example.photograph.controller;

import com.example.photograph.domain.SysOrderItem;
import com.example.photograph.domain.SysUser;
import com.example.photograph.domain.VoPerInfo;
import com.example.photograph.page.TableDataInfo;
import com.example.photograph.service.ISysOrderItemService;
import com.example.photograph.service.ISysUserService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 工作量详情Controller
 * 
 * @author wuyj
 * @date 2021-03-06
 */
@Controller
@RequestMapping("/photograph/workload")
public class SysWorkloadController extends BaseController
{
    private String prefix = "photograph/workload";

    @Autowired
    private ISysOrderItemService sysOrderItemService;
    @Autowired
    private ISysUserService sysUserService;

    @RequiresPermissions("photograph:workload:view")
    @GetMapping()
    public String workload()
    {
        return prefix + "/workload";
    }

    /**
     * 查询员工工作量列表
     */
    @RequiresPermissions("photograph:workload:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(SysOrderItem sysOrderItem)
    {
        startPage();
        List<SysOrderItem> list = sysOrderItemService.selectWorkloadList(sysOrderItem);
        return getDataTable(list);
    }

    @RequiresPermissions("photograph:performance:view")
    @GetMapping("/performance")
    public String performance()
    {
        return prefix + "/performance";
    }

    /**
     * 查询个人综合业绩查询列表
     */
    @RequiresPermissions("photograph:performance:list")
    @PostMapping("/perList")
    @ResponseBody
    public TableDataInfo perList(SysUser sysUser)
    {
        startPage();
        List<SysUser> list = sysUserService.selectStaffList(sysUser);
        return getDataTable(list);
    }

    /**
     * 个人综合业绩详情
     */
    @GetMapping("/perInfo/{userId}")
    public String perInfo(@PathVariable("userId") Long userId, ModelMap mmap)
    {
        List<VoPerInfo> perInfoList = sysOrderItemService.selectPerInfoByUserId(userId);
        mmap.put("perInfoList", perInfoList);
        return prefix + "/info";
    }

}
